{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pylab as plt\n",
    "import datetime\n",
    "\n",
    "from sklearn.preprocessing import LabelBinarizer\n",
    "from sklearn.utils import shuffle\n",
    "from collections import Counter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda2/lib/python2.7/site-packages/h5py/__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
      "  from ._conv import register_converters as _register_converters\n",
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "from keras.models import Model\n",
    "from keras.layers import Dense, Dropout, GlobalAveragePooling1D, GaussianNoise, Conv1D, MaxPool1D, GlobalMaxPooling1D\n",
    "from keras.layers import Input, concatenate, SpatialDropout1D, Flatten, AvgPool1D, LSTM, Lambda, Reshape, GaussianDropout\n",
    "from keras.layers import BatchNormalization\n",
    "from keras.callbacks import ModelCheckpoint, EarlyStopping\n",
    "from keras import regularizers\n",
    "from keras.optimizers import RMSprop, Adam, SGD, Nadam\n",
    "import keras.backend as K\n",
    "from keras.regularizers import l1, l2 , l1_l2\n",
    "\n",
    "\n",
    "from sklearn.metrics import confusion_matrix\n",
    "from sklearn.metrics import classification_report, accuracy_score\n",
    "from sklearn.metrics import r2_score\n",
    "from sklearn.metrics import matthews_corrcoef\n",
    "from sklearn.metrics import f1_score"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Data loading"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "tick_bars = pd.read_csv('tick_bars.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "out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J4ys9oZEnvcMjnRZwwX+Gqv0MObzKwO8AZwjXPu59B9FTl+51ye\nc+4QAnfHfYEuaQ4pJmZ2ErDROTcn3bHEqb9zrjdwIjDazAaE7qzAn5ksAt2sTzjnegE7CHTVBFXg\n2OOWyYm+1AXI02yDmbUA8H5v9OqLi7uk+lZR6pPGzKoRSPIvOOf+m2nxAzjntgIfEOiyaGBmBaun\nhV4vGKO3vz6wqZTYU/UZOxI4xczWAC8T6L55KENixzm33vu9EXiTwJdsJnxm1gHrnHMzve3XCST+\nTIg9funuO0qgry2LwAOQdhQ+bOqWxniyCe+jv5/whzt/9crDCH+4M8urb0Sg77Ch97MaaOTtK/pw\nZ2gS4zbgeeAfReorfPxAU6CBV94P+Bg4CXiN8Aeao7zyaMIfaL7qlbsR/kBzFYGHmeXyGQMGUfgw\ntsLHDtQG6oaUPwNOyITPjHfuj4HOXnmsF3dGxB73P3O6A0jwP9hQAqNEvgFuSWMcLwE/AHsJ3DGM\nJNB/Oh34GpgW8iEw4DEv5kVATsh5fgus9H4uCanPARZ7xzxKkQdJCcben8CfqQuB+d7P0EyIHzgY\nmOfFvhi4zas/0PufbSWBxFnDq6/pba/09h8Ycq5bvPhWEDJKojw+Y4Qn+gofuxfjAu9nScG5M+Ez\n4537EGC297n5H4FEnRGxx/ujN2NFRCq5TO6jFxGRGCjRi4hUckr0IiKVnBK9iEglp0QvIlLJKdGL\niFRySvQiIpWcEr2ISCX3/6RNaVnziObMAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.plot(tick_bars.close[:int(len(tick_bars) * 0.5)])\n",
    "plt.plot(tick_bars.close[int(len(tick_bars) * 0.5):int(len(tick_bars) * 0.7)])\n",
    "plt.plot(tick_bars.close[int(len(tick_bars) * 0.7):])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Making features"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from scipy.stats import entropy\n",
    "from scipy import stats"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "N_BARS = 64000\n",
    "WINDOW_LONG = 100\n",
    "WINDOW_SHORT = 50\n",
    "HORIZON = 25\n",
    "T = 0.01\n",
    "H = 0.05"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAFa9JREFUeJzt3X+QnVV9x/H3l/AztSUkWSnNhm4o\nmArtNDo7/HLGSUkkPwDDCCJtwWhx1hGYMS2ZmiAOaiADVkp0alIzwhCxmqRQhxDiOEkkg50oEGD9\nEeKSFeJkU5D8AoUAnei3f9yTeAm77N3de87ZZ8/nNXNnn+c85977/Waz93vPOc99rrk7IiJSnqNy\nByAiInmoAIiIFEoFQESkUCoAIiKFUgEQESmUCoCISKFUAERECqUCICJSKBUAEZFCHZ07gLczfvx4\nb2tryx2GDFNdXV0ATJ48OXMk6ZSYswzcE088scfdW/rrN6wLQFtbG1u2bMkdhgxTU6dOBWDTpk1Z\n40ipxJxl4MzsV4300xSQiEihhvUIQOTt3HTTTblDSK7EnCUeFQCprOnTp+cOIbkSc5Z4NAUkldXZ\n2UlnZ2fuMJIqMWeJRyMAqax58+YBZS2IlpizxKMRgIhIoVQAREQKpQIgIlIoFQARkUJpEVgqa/Hi\nxVmfv23BQ4e3d9x2UZLnzJ2zjCwqAFJZ559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3oa7T+/rmJn92sxOcffnzewU4MVeuu0CptbttwKbgPOAdjPbQe13\n8E4z2+TuU8ksYs6HLAe2u/uSJoQbQ7+XK6nr0xMK2onA3gbvOxwNJWfMrBX4LvBRd/9l/HCbYig5\nnwNcbmZfAsYAvzez19393+OH3WS5FyGqegP+lTcviH6plz5jqc0TnhRuzwFjj+jTRnUWgYeUM7X1\njvuBo3Ln8jY5Hk1t4XoSf1gcPOuIPtfx5sXB1WH7LN68CPws1VgEHkrOY0L/D+XOI1XOR/T5PBVe\nBM4eQFVv1OY/NwLbgQ11L3Lt1L7p7FC/f6S2GNgNfLyXx6lSARh0ztTeYTmwDegMt0/kzqmPPGcD\nz1A7S+Szoe2LwAfD9vHUzv7oBh4DTqu772fD/boYhmc5NTtn4Cbg1brfaSfwztz5xP491z1GpQuA\nPgksIlIonQUkIlIoFQARkUKpAIiIFEoFQESkUCoAIiKFUgEQESmUCoCISKFUAERECvX/7pKMaqZ6\nsTAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.hist(np.clip(tick_bars.close.pct_change(HORIZON), -H, H).dropna(), bins = 100)\n",
    "plt.axvline(-T, color = 'black', ls = '--')\n",
    "plt.axvline(T, color = 'black', ls = '--')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-0.04359708998044693\n",
      "(30474097.664683025, 0.0)\n",
      "(0.727247953414917, 0.0)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda2/lib/python2.7/site-packages/scipy/stats/morestats.py:1310: UserWarning: p-value may not be accurate for N > 5000.\n",
      "  warnings.warn(\"p-value may not be accurate for N > 5000.\")\n"
     ]
    }
   ],
   "source": [
    "print pd.Series.autocorr(np.clip(tick_bars.close.pct_change(), -H, H).dropna())\n",
    "print stats.jarque_bera(np.clip(tick_bars.close.pct_change(), -H, H).dropna())\n",
    "print stats.shapiro(np.clip(tick_bars.close.pct_change(), -H, H).dropna())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "tick_bars['pct_change'] = np.clip(tick_bars.close.pct_change(), -H, H)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['pct_change']\n"
     ]
    }
   ],
   "source": [
    "FEATURES = ['pct_change']\n",
    "print FEATURES"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def make_features_from_window(X_train_b, X_val, X_test, features):   \n",
    "    \n",
    "    X_train_normts = np.array([(x.close - x.close.iloc[0]) / np.std(x.close) for x in X_train_b]).reshape((len(X_train_b), WINDOW_LONG, 1))\n",
    "    X_val_normts = np.array([(x.close - x.close.iloc[0]) / np.std(x.close) for x in X_val]).reshape((len(X_val), WINDOW_LONG, 1))\n",
    "    X_test_normts = np.array([(x.close - x.close.iloc[0]) / np.std(x.close) for x in X_test]).reshape((len(X_test), WINDOW_LONG, 1))\n",
    "    \n",
    "    X_train_normv = np.array([(x.volume - x.volume.iloc[0]) / np.std(x.volume) for x in X_train_b]).reshape((len(X_train_b), WINDOW_LONG, 1))\n",
    "    X_val_normvv = np.array([(x.volume - x.volume.iloc[0]) / np.std(x.volume) for x in X_val]).reshape((len(X_val), WINDOW_LONG, 1))\n",
    "    X_test_normv = np.array([(x.volume - x.volume.iloc[0]) / np.std(x.volume) for x in X_test]).reshape((len(X_test), WINDOW_LONG, 1))\n",
    "  \n",
    "    X_train = np.array([x[features].fillna(0.).values.tolist() for x in X_train_b]) \n",
    "    X_val = np.array([x[features].fillna(0.).values.tolist() for x in X_val])\n",
    "    X_test = np.array([x[features].fillna(0.).values.tolist() for x in X_test])\n",
    "\n",
    "    X_train = np.concatenate((X_train, X_train_normts, X_train_normv), axis = -1)\n",
    "    X_val = np.concatenate((X_val, X_val_normts, X_val_normvv), axis = -1)\n",
    "    X_test = np.concatenate((X_test, X_test_normts, X_test_normv), axis = -1)\n",
    "    \n",
    "    return X_train, X_val, X_test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def get_class_weights(y):\n",
    "    y = [np.argmax(x) for x in y]\n",
    "    counter = Counter(y)\n",
    "    majority = max(counter.values())\n",
    "    return  {cls: round(float(majority)/float(count), 2) for cls, count in counter.items()}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Fixed horizon"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "X, labels = [], []\n",
    "for i in range(WINDOW_LONG, N_BARS, 1):\n",
    "    \n",
    "    window = tick_bars.iloc[i-WINDOW_LONG:i]\n",
    "#     window = tick_bars.iloc[i]\n",
    "    now = tick_bars.close[i]\n",
    "    future = tick_bars.close[i+HORIZON]\n",
    "    ret = (future - now) / now\n",
    "    \n",
    "    X.append(window)\n",
    "    if ret > T:\n",
    "        labels.append(1)\n",
    "    elif ret < -T:\n",
    "        labels.append(-1)\n",
    "    else:\n",
    "        labels.append(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAE4xJREFUe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EySM4H3AU9Men+1n92XGR2PveuoZYu5v8b5\nmpdhv1cC97X9sxPYktHVTOcB64CvHkcv8+orybuB/wB8oKoODeoz/kyXsa+zB7MfAJ5s07uBS1p/\nq4BL+PF30EvaV+vtnYxO8P7RoLaU+2suO4Gr21VLG4GX24ufpdlXi3m2/US6AX+H0bG3V4Dngd2t\n/lPArsG4y4FvMkr+Twzq72D0j3cK+M/AqYvU19uAe4H9wFeAM1p9A/D5wbi1jF4RvOmo9e8DHmP0\nR+53gZ9crr6Av9Ye++vtftuJsL+AXwL+FHhkcDt/KfbXTL8vjA5TfaBNv7k9/6m2P94xWPcTbb2n\ngMsW+fd9rr6+0v4dTO+fnXP9TJepr38NPN4e/37gnYN1/0Hbj1PAR5azrzb/L4FPH7Xeku0vRi8E\nn2u/ywcYnRv6VeBX2/Iw+k/Rnm6PvWGw7qLvKz8hLUnqnOyHlSRJMzAcJEkdw0GS1DEcJEkdw0GS\n1DEcJEkdw0GS1DEcJEmd/w8bM79CUvwezgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.hist(labels, bins = 5, alpha = 0.7)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X_train, X_val, X_test = X[:int(len(X) * 0.5)], X[int(len(X) * 0.6):int(len(X) * 0.7)], X[int(len(X) * 0.8):]\n",
    "Y_train, Y_val, Y_test = labels[:int(len(X) * 0.5)], labels[int(len(X) * 0.6):int(len(X) * 0.7)], labels[int(len(X) * 0.8):]\n",
    "\n",
    "lbr = LabelBinarizer()\n",
    "Y_train = lbr.fit_transform(Y_train)\n",
    "Y_val = lbr.transform(Y_val)\n",
    "Y_test = lbr.transform(Y_test)\n",
    "\n",
    "X_train, X_val, X_test = make_features_from_window(X_train, X_val, X_test, FEATURES)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "main_input (InputLayer)      (None, 100, 3)            0         \n",
      "_________________________________________________________________\n",
      "flatten_1 (Flatten)          (None, 300)               0         \n",
      "_________________________________________________________________\n",
      "dropout_1 (Dropout)          (None, 300)               0         \n",
      "_________________________________________________________________\n",
      "dense_1 (Dense)              (None, 3)                 903       \n",
      "=================================================================\n",
      "Total params: 903\n",
      "Trainable params: 903\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n",
      "Train on 31950 samples, validate on 6390 samples\n",
      "Epoch 1/100\n",
      "31950/31950 [==============================] - 6s 179us/step - loss: 4.1670 - acc: 0.3157 - val_loss: 1.4236 - val_acc: 0.2360\n",
      "Epoch 2/100\n",
      "31950/31950 [==============================] - 6s 179us/step - loss: 4.1343 - acc: 0.3158 - val_loss: 1.9156 - val_acc: 0.1768\n",
      "Epoch 3/100\n",
      "31950/31950 [==============================] - 6s 177us/step - loss: 4.1417 - acc: 0.3126 - val_loss: 1.6744 - val_acc: 0.2171\n",
      "Epoch 4/100\n",
      "31950/31950 [==============================] - 6s 192us/step - loss: 4.2166 - acc: 0.3118 - val_loss: 1.3438 - val_acc: 0.3152\n",
      "Epoch 5/100\n",
      "31950/31950 [==============================] - 6s 189us/step - loss: 4.1442 - acc: 0.3108 - val_loss: 1.6506 - val_acc: 0.3433\n",
      "Epoch 6/100\n",
      "31950/31950 [==============================] - 5s 169us/step - loss: 4.1671 - acc: 0.3121 - val_loss: 1.5837 - val_acc: 0.2828\n",
      "Epoch 7/100\n",
      "31950/31950 [==============================] - 5s 163us/step - loss: 4.1246 - acc: 0.3140 - val_loss: 1.9486 - val_acc: 0.2042\n",
      "Epoch 8/100\n",
      "31950/31950 [==============================] - 5s 164us/step - loss: 4.1799 - acc: 0.3092 - val_loss: 1.5888 - val_acc: 0.2413\n",
      "Epoch 9/100\n",
      "31950/31950 [==============================] - 7s 207us/step - loss: 4.1771 - acc: 0.3120 - val_loss: 1.6529 - val_acc: 0.3759\n"
     ]
    }
   ],
   "source": [
    "def cnn(shape):\n",
    "    main_input = Input(shape=shape, name='main_input')\n",
    "    x = Flatten()(main_input)\n",
    "    x = Dropout(0.25)(x)\n",
    "    output = Dense(3, activation = \"softmax\")(x)\n",
    "    \n",
    "    final_model = Model(inputs=[main_input], outputs=[output])\n",
    "    return final_model\n",
    "\n",
    "model = cnn((WINDOW_LONG, len(X_train[0][0]), ))\n",
    "model.summary()\n",
    "\n",
    "model.compile(optimizer=Adam(lr = 0.01),  \n",
    "                        loss=['categorical_crossentropy'], \n",
    "                        metrics = ['accuracy'])\n",
    "\n",
    "checkpointer = ModelCheckpoint(filepath=\"test.hdf5\", verbose=0, save_best_only=True)\n",
    "es = EarlyStopping(monitor='val_loss', patience=5)\n",
    "\n",
    "history = model.fit(X_train, Y_train, \n",
    "              epochs = 100, \n",
    "              batch_size = 16, \n",
    "              verbose=True, \n",
    "              validation_data = (X_val, Y_val),\n",
    "              callbacks=[checkpointer, es],\n",
    "              shuffle=True, \n",
    "              class_weight = get_class_weights(np.concatenate((Y_train, Y_val)))\n",
    "                )\n",
    "\n",
    "model.load_weights(\"test.hdf5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.02      0.15      0.04       211\n",
      "           1       0.92      0.32      0.47      5934\n",
      "           2       0.04      0.41      0.06       245\n",
      "\n",
      "   micro avg       0.32      0.32      0.32      6390\n",
      "   macro avg       0.32      0.29      0.19      6390\n",
      "weighted avg       0.85      0.32      0.44      6390\n",
      "\n",
      "[[  32   83   96]\n",
      " [1413 1882 2639]\n",
      " [  57   88  100]]\n"
     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iETq/wEfBfbTBC1JwQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.07      0.22      0.10       899\n",
      "           1       0.87      0.33      0.47     11116\n",
      "           2       0.06      0.46      0.11       765\n",
      "\n",
      "   micro avg       0.33      0.33      0.33     12780\n",
      "   macro avg       0.33      0.33      0.23     12780\n",
      "weighted avg       0.76      0.33      0.43     12780\n",
      "\n",
      "[[ 194  283  422]\n",
      " [2542 3613 4961]\n",
      " [ 147  263  355]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGoNJREFUeJzt3Xt0VeWd//H3t1wMFxWEaBlAoQ6K\nSiDEaKGorQVFYRRdoxVqES0WR2R0nLYjtF0/urys4tJWpVYcVk2NozU6XtHRCmpYdqTcQqPcJaBI\nWKIBhGoFFPj+/jhPmEOehJzkJOck8HmtdVb2fvaz9/6yc8gnez/77Ji7IyIikuxr2S5ARERaHoWD\niIhEFA4iIhJROIiISEThICIiEYWDiIhEFA4iIhJROIiISEThICIikbbZLqCxunfv7n369Ml2GSIi\nrUZZWdlWd89NpW+rDYc+ffqwdOnSbJchItJqmNnGVPvqspKIiEQUDiIiElE4iIhIpNWOOYhI5nz1\n1VdUVlaye/fubJciKcjJyaFXr160a9eu0dtQOIhIvSorKzn66KPp06cPZpbtcuQQ3J1t27ZRWVlJ\n3759G70dXVYSkXrt3r2bbt26KRhaATOjW7duaZ/lKRxEJCUKhtajKb5XCgcREYlozEFEGuy+ee81\n6fZuveCUQy7ftm0bw4cPB2DLli20adOG3NzEB30XL15M+/btU9pPUVERo0aN4utf//oh+1VUVHDF\nFVdQXl5eZ58NGzawePFixo4dm9K+WxuFgxy2mvoHWEtX3w/Y1qxbt24HflD/8pe/pHPnzvzkJz9p\n8HaKioooKCioNxxSsWHDBkpKSg7bcNBlJRFp1YqLizn77LPJz89n8uTJ7N+/n7179zJ+/Hjy8vIY\nMGAAM2fO5KmnnqK8vJyrrrqK/Px8vvzyy4O2s2TJEgYOHEh+fj4PP/zwgfb169dz7rnnMnjwYM48\n80wWLVoEwNSpUyktLSU/P5+ZM2fW2a+10pmDiLRaK1as4Pnnn2fBggW0bduWSZMmUVJSwsknn8zW\nrVtZvnw5ADt27KBLly789re/5cEHHyQ/Pz/a1rXXXsvs2bMZNmwYt95664H2Hj16MG/ePHJycliz\nZg0TJkxg0aJFzJgxgwcffJAXXngBgC+++KLWfq2VwkFEWq3XX3+dJUuWUFhYCMCuXbvo3bs3I0eO\nZO3atdx8882MHj2aCy+88JDb2bp1K7t27WLYsGEAjB8/ntLSUgD27NnDlClTeOedd2jbti3r16+v\ndRup9mstFA4i0mq5Oz/84Q+54447omXvvvsur776Kr/73e949tlnmT17dqP28etf/5revXvz+OOP\n89VXX9G5c+e0+rUWGnMQkVZrxIgRPP3002zduhVI3NX04YcfUlVVhbtz5ZVXcvvtt7Ns2TIAjj76\naD777LNoO927d6dDhw785S9/AeCJJ544sGznzp306NEDM6O4uBh3r3VbdfVrrXTmICIN1lLujMrL\ny2P69OmMGDGC/fv3065dOx5++GHatGnDxIkTcXfMjLvvvhuA6667juuvv54OHTpEt8D+4Q9/4Prr\nr+drX/saF1xwwYH2KVOmcMUVV1BUVMTo0aM56qijABg8eDD79u1j0KBBTJw4sc5+rZW11nQrLCx0\n/bEfORTdytp0Vq9ezWmnndZs25emV9v3zMzK3L0wlfV1WUlERCIKBxERiSgcREQkonAQEZGIwkFE\nRCIKBxERiehzDiLScKW/atrtnT+t3i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P4/Cd63q3PVCA4AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pred = model.predict(X_val)\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_val], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\n",
    "\n",
    "pred = model.predict(X_test)\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_test], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.27972084, 0.67968315, 0.04059596],\n",
       "       [0.49318126, 0.46420133, 0.04261736],\n",
       "       [0.05589748, 0.77083486, 0.1732677 ],\n",
       "       ...,\n",
       "       [0.676218  , 0.16055585, 0.16322614],\n",
       "       [0.20033889, 0.18110037, 0.61856073],\n",
       "       [0.05610908, 0.13044934, 0.8134416 ]], dtype=float32)"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pred"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Volatility horizon"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "X, labels = [], []\n",
    "for i in range(WINDOW_LONG, N_BARS, 1):\n",
    "    window = tick_bars.iloc[i-WINDOW_LONG:i]\n",
    "    now = tick_bars.close[i]\n",
    "    future = tick_bars.close[i+HORIZON]\n",
    "    ret = (future - now) / now\n",
    "    \n",
    "    window_abs_returns = np.abs(window.close.pct_change())\n",
    "    Ti = np.std(window_abs_returns) + np.mean(window_abs_returns)\n",
    "    \n",
    "    X.append(window)\n",
    "    if ret > Ti:\n",
    "        labels.append(1)\n",
    "    elif ret < -Ti:\n",
    "        labels.append(-1)\n",
    "    else:\n",
    "        labels.append(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAE0pJREFUeJzt3X+s3fV93/Hnq3ah3bIMEzyPAolJ\n665zO82hDkHLtOZHZQx/xESjmZEaTOrWaQNTq3VSSPMHUVK0ZFIbCS2lpcXDbG0II43wNKeuQ4ii\nSjWx01LAMOIbkgh7DnYxIZ2ikULe++N8bvuNP/f6Xt9f54KfD+nofM/7++t9Pufi1znf7/ccUlVI\nkjT0A+NuQJK0/BgOkqSO4SBJ6hgOkqSO4SBJ6hgOkqSO4SBJ6hgOkqSO4SBJ6qwcdwNzdcEFF9Ta\ntWvH3YYkvax8+ctf/uuqWj3Tci/bcFi7di0HDx4cdxuS9LKS5BuzWc7DSpKkjuEgSeoYDpKkjuEg\nSeoYDpKkjuEgSeoYDpKkjuEgSeo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ggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.hist(labels, bins = 5, alpha = 0.7)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X_train, X_val, X_test = X[:int(len(X) * 0.5)], X[int(len(X) * 0.6):int(len(X) * 0.7)], X[int(len(X) * 0.8):]\n",
    "Y_train, Y_val, Y_test = labels[:int(len(X) * 0.5)], labels[int(len(X) * 0.6):int(len(X) * 0.7)], labels[int(len(X) * 0.8):]\n",
    "\n",
    "lbr = LabelBinarizer()\n",
    "Y_train = lbr.fit_transform(Y_train)\n",
    "Y_val = lbr.transform(Y_val)\n",
    "Y_test = lbr.transform(Y_test)\n",
    "\n",
    "X_train, X_val, X_test = make_features_from_window(X_train, X_val, X_test, FEATURES)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "main_input (InputLayer)      (None, 100, 3)            0         \n",
      "_________________________________________________________________\n",
      "flatten_2 (Flatten)          (None, 300)               0         \n",
      "_________________________________________________________________\n",
      "dropout_2 (Dropout)          (None, 300)               0         \n",
      "_________________________________________________________________\n",
      "dense_2 (Dense)              (None, 3)                 903       \n",
      "=================================================================\n",
      "Total params: 903\n",
      "Trainable params: 903\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n",
      "Train on 31950 samples, validate on 6390 samples\n",
      "Epoch 1/100\n",
      "31950/31950 [==============================] - 6s 191us/step - loss: 1.9171 - acc: 0.3330 - val_loss: 1.4332 - val_acc: 0.3546\n",
      "Epoch 2/100\n",
      "31950/31950 [==============================] - 9s 281us/step - loss: 1.9045 - acc: 0.3363 - val_loss: 1.6701 - val_acc: 0.3302\n",
      "Epoch 3/100\n",
      "31950/31950 [==============================] - 7s 209us/step - loss: 1.8894 - acc: 0.3382 - val_loss: 1.3361 - val_acc: 0.3286\n",
      "Epoch 4/100\n",
      "31950/31950 [==============================] - 6s 187us/step - loss: 1.9157 - acc: 0.3359 - val_loss: 1.3701 - val_acc: 0.3094\n",
      "Epoch 5/100\n",
      "31950/31950 [==============================] - 7s 207us/step - loss: 1.9298 - acc: 0.3301 - val_loss: 1.5820 - val_acc: 0.3286\n",
      "Epoch 6/100\n",
      "31950/31950 [==============================] - 7s 205us/step - loss: 1.9317 - acc: 0.3339 - val_loss: 1.2592 - val_acc: 0.3457\n",
      "Epoch 7/100\n",
      "31950/31950 [==============================] - 7s 221us/step - loss: 1.8741 - acc: 0.3351 - val_loss: 1.4276 - val_acc: 0.3285\n",
      "Epoch 8/100\n",
      "31950/31950 [==============================] - 8s 243us/step - loss: 1.8851 - acc: 0.3326 - val_loss: 1.3108 - val_acc: 0.3088\n",
      "Epoch 9/100\n",
      "31950/31950 [==============================] - 6s 199us/step - loss: 1.9460 - acc: 0.3276 - val_loss: 1.4281 - val_acc: 0.3498\n",
      "Epoch 10/100\n",
      "31950/31950 [==============================] - 7s 234us/step - loss: 1.9420 - acc: 0.3289 - val_loss: 1.3733 - val_acc: 0.3743\n",
      "Epoch 11/100\n",
      "31950/31950 [==============================] - 7s 219us/step - loss: 1.9033 - acc: 0.3394 - val_loss: 1.3412 - val_acc: 0.3023\n"
     ]
    }
   ],
   "source": [
    "def cnn(shape):\n",
    "    main_input = Input(shape=shape, name='main_input')\n",
    "    x = Flatten()(main_input)\n",
    "    x = Dropout(0.25)(x)\n",
    "    output = Dense(3, activation = \"softmax\")(x)\n",
    "    \n",
    "    final_model = Model(inputs=[main_input], outputs=[output])\n",
    "    return final_model\n",
    "\n",
    "model = cnn((WINDOW_LONG, len(X_train[0][0]), ))\n",
    "model.summary()\n",
    "\n",
    "model.compile(optimizer=Adam(lr = 0.01),  \n",
    "                        loss=['categorical_crossentropy'], \n",
    "                        metrics = ['accuracy'])\n",
    "\n",
    "checkpointer = ModelCheckpoint(filepath=\"test.hdf5\", verbose=0, save_best_only=True)\n",
    "es = EarlyStopping(monitor='val_loss', patience=5)\n",
    "\n",
    "history = model.fit(X_train, Y_train, \n",
    "              epochs = 100, \n",
    "              batch_size = 16, \n",
    "              verbose=True, \n",
    "              validation_data = (X_val, Y_val),\n",
    "              callbacks=[checkpointer, es],\n",
    "              shuffle=True, \n",
    "              class_weight = get_class_weights(np.concatenate((Y_train, Y_val)))\n",
    "                )\n",
    "\n",
    "model.load_weights(\"test.hdf5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.33      0.29      0.31      2095\n",
      "           1       0.24      0.31      0.27      1518\n",
      "           2       0.44      0.41      0.42      2777\n",
      "\n",
      "   micro avg       0.35      0.35      0.35      6390\n",
      "   macro avg       0.34      0.34      0.33      6390\n",
      "weighted avg       0.36      0.35      0.35      6390\n",
      "\n",
      "[[ 603  680  812]\n",
      " [ 442  478  598]\n",
      " [ 810  839 1128]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGbtJREFUeJzt3X9wVPW9//Hn2xCMAqMI0fIVFOpg\nEYmENFpSpNWLiMAoZa5WaIuoWLxFrtav7Qi2c3H8McXxV6VaHO41FUcrcqsoOlhBTYe5Ir/ChN8i\nAVFDlV8qhQoo8L5/7Ce5S0jIJtnsEj+vx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KCsrIw77rgDdz9q+/X1E5HWIZUxgIPAHe6+wsw6AOVmtiDMe9TdH0rubGa9gVHA+cD/A940\ns+rvND8BDAaqgGVmNtfd16XjiWTSvn37aq7jP3DgQMaNG8ff//53zj77bPr37w/A4sWLWbduXc1l\nnb/66itKSkp477336NGjBz179gTgZz/7WZ1XB3377bd55plngMSYwymnnMLnn39+RJ/58+czf/58\n+vXrByT+ct+4cSN79uxh5MiRNeMSV111VZ3P45133uHFF18EEpedvvPOO4HEIay77rqLhQsXcsIJ\nJ7B161a2bdt21PL19UvHfzkTSdb/o6ZdQbd1e6jhLs3UYAC4+yfAJ2F6j5mtB848xiIjgFnufgD4\nwMwqgYvCvEp33wxgZrNC31YXANVjALW1a9euZtrdGTx4MM8///wRfY71v30by92ZPHkyN9988xHt\nv//971Neh5kd1fbcc8+xY8cOysvLyc3NpXv37uzfv7/J/UTk+NSoMQAz6w70A6r/vdREM1tlZqVm\n1jG0nQl8nLRYVWirr732Nsab2XIzW75jx47GlHdc6d+/P++88w6VlZUA/POf/+T999+nV69ebNmy\npeaftNQOiGqDBg1i+vTpABw6dIjdu3cfddnnIUOGUFpaWjO2sHXrVrZv384PfvADXn75Zfbt28ee\nPXt49dVX69zGgAEDmDVrFnD0ZadPP/10cnNzKSsr48MPPwTqvux0Xf1EpHVI+TRQM2sPvAj80t3/\nYWbTgXsBD/cPAzc2tyB3nwHMgMTVQBtcIIXTNrMhPz+fp59+mtGjR3PgwAEA7rvvPs4991xmzJjB\n8OHDOfnkkxk4cGCd/xfgscceY/z48Tz11FPk5OQwffp0SkpKGDBgAH369GHo0KE8+OCDrF+/npKS\nEiBxGuezzz5LUVER1157LX379uX000/nwgsvrLPGxx57jJ/85Cc88MADjBgxoqb9pz/9KVdeeSUF\nBQUUFxfTq1cvADp16nTE9u+88846+4lI65DS5aDNLBd4DXjD3R+pY3534DV372NmkwHc/Xdh3hvA\n3aHr3e4+JLQf0a8uuhz0N4N+ZtJc7z517O+wfBOVjGv6GEDaLgd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iKSBgoAEZFIKQBERCKlABARiZQCQEQkUgoAEZFIKQBERCKlABAR\nidT/AqBXHJW5Jpc+AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.37      0.27      0.31      4922\n",
      "           1       0.24      0.33      0.28      2896\n",
      "           2       0.39      0.41      0.40      4962\n",
      "\n",
      "   micro avg       0.34      0.34      0.34     12780\n",
      "   macro avg       0.33      0.34      0.33     12780\n",
      "weighted avg       0.35      0.34      0.34     12780\n",
      "\n",
      "[[1317 1577 2028]\n",
      " [ 814  961 1121]\n",
      " [1443 1504 2015]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGk1JREFUeJzt3X90VPWd//Hn2xAMghWEaDlADa1Y\n/IGEGJUUaWtRQFhBz2rFWkUbS7fK6na/bYW2u7iK38LRVqUqfjlLalytka+KUo+2oODxrMpPi4og\nEhAlqUIIPwoV0MB7/5gP2QESMgMzE/DzepyTk3s/93Pvfc/NZF5zf8wdc3dERCQ+x7R2ASIi0joU\nACIikVIAiIhESgEgIhIpBYCISKQUACIikVIAiIhESgEgIhIpBYCISKTatHYBB9OlSxcvKipq7TJE\nRI4qS5Ys2ejuhS31O6IDoKioiMWLF7d2GSIiRxUz+zCVfjoEJCISKQWAiEikFAAiIpE6os8ByNHv\n888/p6amhp07d7Z2KZKCgoICunfvTn5+fmuXIjmgAJCsqqmp4fjjj6eoqAgza+1y5CDcnfr6empq\naujZs2drlyM5o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plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pred = model.predict(X_val)\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_val], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\n",
    "\n",
    "pred = model.predict(X_test)\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_test], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{0: 1.23, 1: 1.82, 2: 1.0}\n",
      "[-1  0  1]\n"
     ]
    }
   ],
   "source": [
    "print get_class_weights(np.concatenate((Y_train, Y_val)))\n",
    "print lbr.classes_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Meta labeling"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def get_meta_barier(future_window, last_close, min_ret, tp, sl, vertical_zero = False):\n",
    "    '''\n",
    "        XXX\n",
    "    '''\n",
    "    if vertical_zero:\n",
    "        min_ret_situation = [0, 0, 0]\n",
    "    else:\n",
    "        min_ret_situation = [0, 0]\n",
    "        \n",
    "        \n",
    "    differences = np.array([(fc - last_close) / last_close for fc in future_window])\n",
    "    \n",
    "    # Are there gonna be fluctuations within min_ret???\n",
    "    min_ret_ups = np.where((differences >= min_ret) == True)[0]\n",
    "    min_ret_downs = np.where((differences < -min_ret) == True)[0]\n",
    "  \n",
    "    if (len(min_ret_ups) == 0) and (len(min_ret_downs) == 0):\n",
    "        if vertical_zero:\n",
    "            min_ret_situation[2] = 1\n",
    "        else:\n",
    "            if differences[-1] > 0:\n",
    "                min_ret_situation[0] = 1\n",
    "            else:\n",
    "                min_ret_situation[1] = 1            \n",
    "    else:\n",
    "        if len(min_ret_ups) == 0: min_ret_ups = [np.inf]\n",
    "        if len(min_ret_downs) == 0: min_ret_downs = [np.inf]\n",
    "        if min_ret_ups[0] > min_ret_downs[0]:\n",
    "            min_ret_situation[0] = 1\n",
    "        else:\n",
    "            min_ret_situation[1] = 1\n",
    "        \n",
    "    #  Take profit and stop losses indices\n",
    "    take_profit = np.where((differences >= tp) == True)[0]\n",
    "    stop_loss = np.where((differences < sl) == True)[0]\n",
    "    \n",
    "    # Fluctuation directions coincide with take profit / stop loss actions?\n",
    "    if min_ret_situation[0] == 1 and len(take_profit) != 0:\n",
    "        take_action = 1\n",
    "    elif min_ret_situation[1] == 1 and len(stop_loss) != 0:\n",
    "        take_action = 1\n",
    "    else:\n",
    "        take_action = 0.\n",
    "    \n",
    "    return min_ret_situation, take_action"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "TP = T\n",
    "SL = -T\n",
    "\n",
    "X, Y, Y2 = [], [], []\n",
    "for i in range(WINDOW_LONG, N_BARS, 1):\n",
    "    window = tick_bars.iloc[i-WINDOW_LONG:i]\n",
    "    now = tick_bars.close[i]\n",
    "    future_window = tick_bars.close[i:i+HORIZON]\n",
    "    \n",
    "    window_abs_returns = np.abs(window.close.pct_change())\n",
    "    Ti = np.std(window_abs_returns) + np.mean(window_abs_returns)\n",
    "    \n",
    "    min_ret_situation, take_action = get_meta_barier(future_window, now, Ti, TP, SL, True)\n",
    "    X.append(window)\n",
    "    Y.append(min_ret_situation)\n",
    "    Y2.append(take_action)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAFHlJREFUeJzt3X+w3XWd3/Hna8MPXXUlyF3KQDC4\nZscJOxUwg6zrtAgVAp1tcGqdMO0SbbpxK3R03eksrjPFqkz1j106TJUOu2QMHWugqCV1YtkU6Thb\nJ0BQBAILXAOWZBCyhB8yTrHQd/84n7jHfO7NPbk/zg3k+Zg5c7/n/f18v+d9vufkvu73xzlJVSFJ\n0rBfWewGJEmHH8NBktQxHCRJHcNBktQxHCRJHcNBktQxHCRJHcNBktQxHCRJnaMWu4HZOuGEE2r5\n8uWL3YYkvarcc889f1NVEzONe9WGw/Lly9mxY8dityFJrypJfjzKOA8rSZI6hoMkqWM4SJI6hoMk\nqWM4SJI6hoMkqWM4SJI6hoMkqWM4SJI6r9pPSEszuWbbI4vdwtj94ft/c7Fb0GuEew6SpI7hIEnq\nGA6SpI7hIEnqGA6SpI7hIEnqGA6SpI7hIEnqGA6SpM6M4ZDkdUnuSvLDJDuT/NtWPy3JnUkmk9yU\n5JhWP7bdn2zzlw+t61Ot/nCSC4fqq1ttMsmV8/80JUmHYpQ9h5eA86rqncAZwOok5wBfBK6pqrcD\nzwLr2/j1wLOtfk0bR5KVwFrgdGA18OUkS5IsAb4EXASsB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UXwLND768drf62tp1+2F7jT4+5ryuG\n3lvbGQqvqV7/cfXVxnyYwQUqw8st9PZ6L4NzGvcNvVYXL9Z7zE9IS5I6r7VzDpKkeWA4SJI6hoMk\nqWM4SJI6hoMkqWM4SJI6hoMkqWM4SJI6/x+KdjajuQ28NQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.hist([np.argmax(x) for x in Y], alpha = 0.5, bins = 5)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X_train, X_val, X_test = X[:int(len(X) * 0.5)], X[int(len(X) * 0.6):int(len(X) * 0.7)], X[int(len(X) * 0.8):]\n",
    "Y_train, Y_val, Y_test = Y[:int(len(X) * 0.5)], Y[int(len(X) * 0.6):int(len(X) * 0.7)], Y[int(len(X) * 0.8):]\n",
    "\n",
    "X_train, X_val, X_test = make_features_from_window(X_train, X_val, X_test, FEATURES)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "Y_train, Y_val, Y_test = np.array(Y_train), np.array(Y_val), np.array(Y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "main_input (InputLayer)      (None, 100, 3)            0         \n",
      "_________________________________________________________________\n",
      "flatten_3 (Flatten)          (None, 300)               0         \n",
      "_________________________________________________________________\n",
      "dropout_3 (Dropout)          (None, 300)               0         \n",
      "_________________________________________________________________\n",
      "dense_3 (Dense)              (None, 3)                 903       \n",
      "=================================================================\n",
      "Total params: 903\n",
      "Trainable params: 903\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n",
      "Train on 31950 samples, validate on 6390 samples\n",
      "Epoch 1/100\n",
      "31950/31950 [==============================] - 6s 203us/step - loss: 3.2392 - acc: 0.3451 - val_loss: 2.1423 - val_acc: 0.3293\n",
      "Epoch 2/100\n",
      "31950/31950 [==============================] - 6s 196us/step - loss: 3.3246 - acc: 0.3436 - val_loss: 1.1839 - val_acc: 0.3764\n",
      "Epoch 3/100\n",
      "31950/31950 [==============================] - 6s 196us/step - loss: 3.2117 - acc: 0.3480 - val_loss: 1.4006 - val_acc: 0.3388\n",
      "Epoch 4/100\n",
      "31950/31950 [==============================] - 8s 249us/step - loss: 3.5023 - acc: 0.3459 - val_loss: 1.4190 - val_acc: 0.3488\n",
      "Epoch 5/100\n",
      "31950/31950 [==============================] - 6s 174us/step - loss: 3.3483 - acc: 0.3546 - val_loss: 1.2302 - val_acc: 0.3831\n",
      "Epoch 6/100\n",
      "31950/31950 [==============================] - 6s 179us/step - loss: 3.1861 - acc: 0.3443 - val_loss: 1.7920 - val_acc: 0.3286\n",
      "Epoch 7/100\n",
      "31950/31950 [==============================] - 6s 176us/step - loss: 3.2031 - acc: 0.3422 - val_loss: 4.6242 - val_acc: 0.2419\n"
     ]
    }
   ],
   "source": [
    "def cnn(shape):\n",
    "    main_input = Input(shape=shape, name='main_input')\n",
    "    x = Flatten()(main_input)\n",
    "    x = Dropout(0.25)(x)\n",
    "    output = Dense(3, activation = \"softmax\")(x)\n",
    "    \n",
    "    final_model = Model(inputs=[main_input], outputs=[output])\n",
    "    return final_model\n",
    "\n",
    "model = cnn((WINDOW_LONG, len(X_train[0][0]), ))\n",
    "model.summary()\n",
    "\n",
    "model.compile(optimizer=Adam(lr = 0.01),  \n",
    "                        loss=['categorical_crossentropy'], \n",
    "                        metrics = ['accuracy'])\n",
    "\n",
    "checkpointer = ModelCheckpoint(filepath=\"test.hdf5\", verbose=0, save_best_only=True)\n",
    "es = EarlyStopping(monitor='val_loss', patience=5)\n",
    "\n",
    "history = model.fit(X_train, Y_train, \n",
    "              epochs = 100, \n",
    "              batch_size = 16, \n",
    "              verbose=True, \n",
    "              validation_data = (X_val, Y_val),\n",
    "              callbacks=[checkpointer, es],\n",
    "              shuffle=True, \n",
    "              class_weight = get_class_weights(np.concatenate((Y_train, Y_val)))\n",
    "                )\n",
    "\n",
    "model.load_weights(\"test.hdf5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.44      0.39      0.41      2865\n",
      "           1       0.52      0.37      0.43      3307\n",
      "           2       0.04      0.25      0.06       218\n",
      "\n",
      "   micro avg       0.38      0.38      0.38      6390\n",
      "   macro avg       0.33      0.34      0.30      6390\n",
      "weighted avg       0.47      0.38      0.41      6390\n",
      "\n",
      "[[1130 1066  669]\n",
      " [1362 1221  724]\n",
      " [ 101   63   54]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGxpJREFUeJzt3X+QFOW97/H3R364CkYR0HCECEkw\n+ANZ1tVAkCQGFcQKxLoaMYmiweCJcjW5J4mYpC5ef1S0TDQaDRbnuBGPRvRGUZLCBFRS1lH56UVE\nEFkQI0RhQSUQFV383j/mWc4Au+zs7uwsa39eVVPb8+2nu5/pnZ3Pdj8zPYoIzMwsew5o6w6YmVnb\ncACYmWWUA8DMLKMcAGZmGeUAMDPLKAeAmVlGOQDMzDLKAWBmllEOADOzjOrY1h3Ylx49ekTfvn3b\nuhtmZu3KkiVLNkdEz8ba7dcB0LdvXxYvXtzW3TAza1ckvV5IO58CMjPLKAeAmVlGOQDMzDJqvx4D\nMLPS+uijj1i/fj0ffPBBW3fFClBWVkbv3r3p1KlTs5Z3AJjZLuvXr+eQQw6hb9++SGrr7tg+RARb\ntmxh/fr19OvXr1nr8CkgM9vlgw8+oHv37n7xbwck0b179xYdrTkAzGw3fvFvP1r6u3IAmJlllMcA\nzKxBt819tajr++EZx+xz/pYtWxgxYgQAb731Fh06dKBnz9wHWhcuXEjnzp0L2k5VVRWjR4/m05/+\n9D7bVVdXc+6557J06dIG26xdu5aFCxcybty4grbdnjgArF0r9gtUe9DYi2h71r17910vxtdeey1d\nu3blRz/6UZPXU1VVRUVFRaMBUIi1a9cyY8aMT2QA+BSQmbUL06dP55RTTqG8vJzLL7+cjz/+mNra\nWi688EIGDhzICSecwB133MFDDz3E0qVLOf/88ykvL+fDDz/cbT2LFi3ixBNPpLy8nLvvvntXfc2a\nNQwfPpzBgwdz0kknsWDBAgAmT57MvHnzKC8v54477miwXXvkIwAz2+8tX76cmTNn8txzz9GxY0cm\nTpzIjBkz+NznPsfmzZt56aWXAHj33Xc57LDD+M1vfsOdd95JeXn5Xuu6+OKLmTZtGsOGDeOHP/zh\nrnqvXr2YO3cuZWVlvPLKK4wfP54FCxZw0003ceedd/LYY48B8N5779Xbrj1yAJjZfu/JJ59k0aJF\nVFZWAvD+++/Tp08fRo4cyapVq7jyyis5++yzOfPMM/e5ns2bN/P+++8zbNgwAC688ELmzZsHwI4d\nO5g0aRIvvvgiHTt2ZM2aNfWuo9B27YEDwMz2exHBd7/7Xa6//vq95i1btownnniCu+66i0ceeYRp\n06Y1axu/+tWv6NOnD/fffz8fffQRXbt2bVG79sBjAGa23zv99NN5+OGH2bx5M5B7t9Df/vY3ampq\niAjOO+88rrvuOl544QUADjnkELZt27bXenr06MFBBx3E888/D8ADDzywa97WrVvp1asXkpg+fToR\nUe+6GmrXHvkIwMwatL+842jgwIFMmTKF008/nY8//phOnTpx991306FDByZMmEBEIImbb74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r/571LsB\nB6bpHsBqijQYVmC/euVNnwPMj/8ecHot9a9bmj68VP1K7QaQG5BTKfZX3jb60vCg5tnsPkC3sLX3\nV4H9+gy5ca0v7VHvAhySN/0cuYsylqpfn677/ZF7If1b2ncFPQdaq19p/qHkxgm6lGp/pcd+H/Dr\nfbQpyXOsaDu6lDdyI+Svknsx/VmqXUfuv2qAMuD/pj+GhcBn85b9WVpuFXBWifv1JLARWJpus1L9\nS8BL6Q/gJWBCifv1C+DltP15wIC8Zb+b9mM1cEkp+5XuXwvctMdyrb2/HgTeBD4id451AvCvwL+m\n+SL3xUZr0vYrS7S/GuvXfwDv5D2/Fqf6Z9O+ejH9nn9W4n5Nynt+zScvoOp7DpSqX6nNxeTeGJK/\nXGvvr1PJjTEsy/tdjW6L55g/CWxmllHtcQzAzMyKwAFgZpZRDgAzs4xyAJiZZZQDwMwsoxwAZmYZ\n5QAwM8soB4CZWUb9fxGinjHgDM0PAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.49      0.41      0.45      6225\n",
      "           1       0.49      0.38      0.43      6189\n",
      "           2       0.03      0.23      0.05       366\n",
      "\n",
      "   micro avg       0.39      0.39      0.39     12780\n",
      "   macro avg       0.34      0.34      0.31     12780\n",
      "weighted avg       0.48      0.39      0.43     12780\n",
      "\n",
      "[[2541 2329 1355]\n",
      " [2491 2364 1334]\n",
      " [ 142  138   86]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcm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QX4Bl332dm3yOx9/TNLK07FWOBZ939QFJbc26vFs3MriIRAJcnNV8e\nttcZQKmZvR/+Q86Gd0j8vnab2UjgBaB3ltadimuBt9w9eW8h49vLzE4hETr/4e7/SOeyU3Ui7gE0\nejuJ5D5m1gY4Ddia4ryZrAszGwr8DBjt7vtq2929OvxcD7xB4r+CrNTl7luTavk9cFGq82ayriRj\nOWz3PIPbKxUN1Z7J7ZUSM/s6id/hGHffWtuetL02A3NJ36HPRrn7P9x9dxh+GWhrZl1oAdsrONrr\nKyPby8zaknjzf9rdn6+nS3ZeY5k4yZHJB4m9lvUkDgnUnji64LA+d3DoSeA5YfgCDj0JvJ70nQRO\npa4BJE569T6svRNwUhjuAlSQppNhKdbVLWn4emCx//cJpw9DfZ3C8OnZqiv060PihJxlY3slraMn\nDZ/UHMWhJ+iWZnp7pVjXV0ic17rssPYOwKlJw2+TuCljtur6cu3vj8Qb6cdh26X0GshUXWH6aSTO\nE3TI1vYKz/0p4OGj9MnKayxtGzqbDxJnyD8g8Wb6s9B2L4n/qgFygP8X/hiWAl9NmvdnYb61wDVZ\nrut1YBNQHh7zQvtlwMrwB7ASKMxyXb8G3gvrXwT0SZr3trAdK4GJ2awrjP8SmHrYfJneXs8AnwD/\nInGMtRD4N+DfwnQj8cVG68L687O0vRqr6/fA9qTXV1lo/2rYVu+G3/PPslzXpKTX12KSAqq+10C2\n6gp9JpC4MCR5vkxvr8tJnGNYkfS7GtkcrzF9ElhEJFIn4jkAERFJAwWAiEikFAAiIpFSAIiIREoB\nICISKQWAiEikFAAiIpFSAIiIROr/A+148tVul92oAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pred = model.predict(X_val)\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_val], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\n",
    "\n",
    "pred = model.predict(X_test)\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_test], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "X_train, X_val, X_test = X[:int(len(X) * 0.5)], X[int(len(X) * 0.6):int(len(X) * 0.7)], X[int(len(X) * 0.8):]\n",
    "Y_train, Y_val, Y_test = Y2[:int(len(X) * 0.5)], Y2[int(len(X) * 0.6):int(len(X) * 0.7)], Y2[int(len(X) * 0.8):]\n",
    "\n",
    "X_train, X_val, X_test = make_features_from_window(X_train, X_val, X_test, FEATURES)\n",
    "P_train, P_val, P_test = model.predict(X_train), model.predict(X_val), model.predict(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "Y_train = np.array([[1, 0] if x == 1 else [0, 1] for x in Y_train])\n",
    "Y_val = np.array([[1, 0] if x == 1 else [0, 1] for x in Y_val])\n",
    "Y_test = np.array([[1, 0] if x == 1 else [0, 1] for x in Y_test])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "__________________________________________________________________________________________________\n",
      "Layer (type)                    Output Shape         Param #     Connected to                     \n",
      "==================================================================================================\n",
      "main_input (InputLayer)         (None, 100, 3)       0                                            \n",
      "__________________________________________________________________________________________________\n",
      "flatten_4 (Flatten)             (None, 300)          0           main_input[0][0]                 \n",
      "__________________________________________________________________________________________________\n",
      "dropout_4 (Dropout)             (None, 300)          0           flatten_4[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "meta (InputLayer)               (None, 3)            0                                            \n",
      "__________________________________________________________________________________________________\n",
      "concatenate_1 (Concatenate)     (None, 303)          0           dropout_4[0][0]                  \n",
      "                                                                 meta[0][0]                       \n",
      "__________________________________________________________________________________________________\n",
      "dense_4 (Dense)                 (None, 2)            608         concatenate_1[0][0]              \n",
      "==================================================================================================\n",
      "Total params: 608\n",
      "Trainable params: 608\n",
      "Non-trainable params: 0\n",
      "__________________________________________________________________________________________________\n",
      "Train on 31950 samples, validate on 12780 samples\n",
      "Epoch 1/100\n",
      "31950/31950 [==============================] - 6s 198us/step - loss: 2.9098 - acc: 0.4804 - val_loss: 1.0998 - val_acc: 0.3777\n",
      "Epoch 2/100\n",
      "31950/31950 [==============================] - 5s 167us/step - loss: 2.8330 - acc: 0.4821 - val_loss: 1.3706 - val_acc: 0.3956\n",
      "Epoch 3/100\n",
      "31950/31950 [==============================] - 5s 156us/step - loss: 2.8462 - acc: 0.4787 - val_loss: 1.3436 - val_acc: 0.3833\n",
      "Epoch 4/100\n",
      "31950/31950 [==============================] - 5s 156us/step - loss: 2.9461 - acc: 0.4768 - val_loss: 1.5707 - val_acc: 0.4860\n",
      "Epoch 5/100\n",
      "31950/31950 [==============================] - 5s 157us/step - loss: 2.7058 - acc: 0.4846 - val_loss: 1.6371 - val_acc: 0.5117\n",
      "Epoch 6/100\n",
      "31950/31950 [==============================] - 5s 156us/step - loss: 2.9673 - acc: 0.4821 - val_loss: 1.9138 - val_acc: 0.3987\n"
     ]
    }
   ],
   "source": [
    "def cnn(shape):\n",
    "    main_input = Input(shape=shape, name='main_input')\n",
    "    aux_input = Input((3, ), name='meta')\n",
    "    \n",
    "    x = Flatten()(main_input)\n",
    "    x = Dropout(0.25)(x)\n",
    "    x = concatenate([x, aux_input])\n",
    "    output = Dense(2, activation = \"softmax\")(x)\n",
    "    \n",
    "    final_model = Model(inputs=[main_input, aux_input], outputs=[output])\n",
    "    return final_model\n",
    "\n",
    "\n",
    "model = cnn((WINDOW_LONG, len(X_train[0][0]), ))\n",
    "model.summary()\n",
    "\n",
    "model.compile(optimizer=Adam(lr = 0.01),  \n",
    "                        loss=['categorical_crossentropy'], \n",
    "                        metrics = ['accuracy'])\n",
    "\n",
    "checkpointer = ModelCheckpoint(filepath=\"test.hdf5\", verbose=0, save_best_only=True)\n",
    "es = EarlyStopping(monitor='val_loss', patience=5)\n",
    "\n",
    "history = model.fit([X_train, P_train], Y_train, \n",
    "              epochs = 100, \n",
    "              batch_size = 16, \n",
    "              verbose=True, \n",
    "              validation_data = ([X_test, P_test], Y_test),\n",
    "              callbacks=[checkpointer, es],\n",
    "              shuffle=True, \n",
    "              class_weight = get_class_weights(np.concatenate((Y_train, Y_val))))\n",
    "\n",
    "model.load_weights(\"test.hdf5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.02      0.59      0.03       120\n",
      "           1       0.98      0.38      0.55      6270\n",
      "\n",
      "   micro avg       0.38      0.38      0.38      6390\n",
      "   macro avg       0.50      0.49      0.29      6390\n",
      "weighted avg       0.96      0.38      0.54      6390\n",
      "\n",
      "[[  71   49]\n",
      " [3897 2373]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAA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23mtmdwOLQ7g5335qWUYiISIulFADuvozE9M1DDW6krQM3NrGfKqCqJR0UEZG2kft/CTzv\n39O7vwtua7ZJu3btKCoqor6+njPPPJPq6mqOO+64IzrcG2+8we9+9ztefPFFZs2axcqVK5k4cWKj\nbbdv385TTz3FDTfc0KJjpPrU0i5durBr164mtx/p8UXk6KSngR6BTp06sWzZMlasWEHHjh0PemIn\nJB4LsX///hbvd+TIkU3+8ofEL+CHH364xftNl2wfX0TSSwHQSoMGDaKmpoaPP/6YM844g7Fjx9Kv\nXz/Wr1/P7NmzKS8vp6SkhMsuu6zh3fUrr7xC3759KSkp4S9/+UvDvh577DEmTJgAwMaNG7n00kvp\n378//fv356233mLixImsXbuW4uJifvWrXwFwzz33cO6553L22WczadKkhn3dfffdnH766Xzve99j\n9erVjfb9o48+ory8nKKiIn7zm9801Hft2sXgwYMpKSmhqKiIF15I3N8/9PhNtROR3JD7l4CyqL6+\nnpdffplhw4YBsGbNGqqrqykrK2Pz5s3cddddvPbaa3Tu3JkpU6Zw33338etf/5qf//znzJ07l9NO\nO40rrrii0X3fdNNN/OAHP2DmzJns27ePXbt2MXnyZFasWNHwgTSzZ89mzZo1LFq0CHdn5MiRzJ8/\nn86dOzN9+nSWLVtGfX09JSUlnHPOOYcd4+abb+b6669n7NixPPTQQw31vLw8Zs6cyQknnMDmzZsp\nKytj5MiRhx2/vr6+0Xb6HGCR3KAAOAK7d+9ueI7/oEGDqKio4O9//zvf+c53KCsrA2DBggWsXLmy\n4bHOX375JeXl5XzwwQf07t2bPn36AHDVVVc1+nTQuXPn8vjjjwOJew4nnngi27Yd/Nik2bNnM3v2\nbAYMGAAk3rmvWbOGnTt3cumllzbclxg5cmSj43jzzTd57rnngMRjp2+99VYgcQnr9ttvZ/78+Rxz\nzDFs2LCBjRs3Hvb6ptql41PORKTtKQCOwIF7AIfq3Llzw7K7c9FFF/H00wc/6ujrPtu3pdyd2267\njV/84hcH1X//+9+nvI/G3q0/+eST1NXVsXTpUjp06EBhY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dC929kMR9j5HuviQ73U2LVP5tP0/i3T9m1p3EJaF1mexkmqUy5k+BwQBmdiaJAKjLaC8zaxYw\nNswGKgN2uPtn6dp5Tl8C8iYeLWFmdwBL3H0W8CiJ08QaEjdbxmSvx62X4pjvAboA/y/c7/7U3Udm\nrdOtlOKYv1FSHPOrwBAzWwnsA37l7jl7dpvimP8V+L9mdguJG8LX5PIbOjN7mkSIdw/3NSYBHQDc\n/RES9zmGAzXAF8C1aT1+Dv+3ExGRVsj1S0AiInKEFAAiIpFSAIiIREoBICISKQWAiEikFAAiIpFS\nAIiIREoBICISqf8PWd51e5ntBIEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.03      0.62      0.05       360\n",
      "           1       0.97      0.37      0.54     12420\n",
      "\n",
      "   micro avg       0.38      0.38      0.38     12780\n",
      "   macro avg       0.50      0.50      0.30     12780\n",
      "weighted avg       0.94      0.38      0.52     12780\n",
      "\n",
      "[[ 225  135]\n",
      " [7818 4602]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGoVJREFUeJzt3Xt0lfWd7/H31wAG0YKFaDkEG6ag\nSEFCjDQsip0WL6hT0DlYsSpoo3R5GT3OtAqdduGyukaWt0pVPDlDamytkbGi1FEBBcs6Kjc1RxFE\nAl4IVQnXgQpo4Hv+2D8yG34J2WZvsnP5vNbKyvP8nt/zPN8fG/js57Kfbe6OiIhIsqOyXYCIiLQ+\nCgcREYkoH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BuxeQuM4y1t1XZKfcjEjl7/UzJI4aMLNeJE4zrW/J\nIjMslTF/DIwGMLNTSYRDbYtW2bLmAhPDXUslwA53/ySTO2i3p5W8kUdymNntwAp3nwvMInH4WU3i\n4s+E7FWcnhTHezdwLPAf4br7x+4+NmtFpynFMbcrKY55HnCOma0C9gE/d/e2ekSc6pj/Bfg/ZnYz\niYvTV7bhN3qY2RMkAr5XuI4yDegM4O6PkLiucj5QDXwOXJXxGtrwn5+IiBwh7fm0koiINJPCQURE\nIgoHERGJKBxERCSicBARkYjCQUREIgoHERGJKBxERCTy/wFhxcVYn8sp8QAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pred = model.predict([X_val, P_val])\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_val], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\n",
    "\n",
    "pred = model.predict([X_test, P_test])\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_test], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs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s+Hfhf6xjfRFTVPcA3TlBlN/CJGrkX\nOCPJtnGcexoS/ZDlFL5bp6qeB54BXr0u0U3GSpeQuJpRT2DaLdvu9uvszqq6bT0Dm6Ahf9evBV6b\n5H8kuTfJJesW3WQMafO1wM8kOcRo9t4/XZ/QNtTElo6Z2PRKrY8kPwPMAX97o2OZtCQvAz4M/OwG\nh7LeTmY0fPNGRr+53ZPkr1fV0xsa1WRdCXy8qj6U5EeAX0/yuqr6zkYHNo2moUe/7HIKi+skOZnR\nr3pfX5foJmNIm0nyd4B/Abylqp5bp9gmabl2vxJ4HfDZJI8zGsc8MOUXZIf8XR8CDlTV/6mqrwD/\nk1Hin1ZD2nw1cAtAVX0eOI3RejA9G/T/fjWmIdEPWU7hAHBV234rcFe1qxtTatk2J3k98B8YJflp\nH7M95oTtrqpnquqsqpqtqllG1ybeUlUHNybcsRjy7/u/MOrNk+QsRkM5j61nkGM2pM1/ClwMkOSv\nMUr0C+sa5fo7ALy9zb65CHimqo6M44M3/dBNHWc5hST/CjhYVQeAGxn9ajfP6GLHFRsX8doNbPO/\nAV4B/Od23flPq+otGxb0GAxsd1cGtvn3gB9P8gjwAvALVTW1v7EObPN7gY8l+WeMLsz+7JR33kjy\nSUZf2Ge1aw/vB04BqKpfY3Qt4lJgHngWeMfYzj3lf3aSpGVMw9CNJGkNTPSS1DkTvSR1zkQvSZ0z\n0UtS50z0ktQ5E70kdc5EL0md+7+d99fv5PVnWgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.hist(pred, bins = 50)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0: 14.8, 1: 1.0}"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_class_weights(np.concatenate((Y_train, Y_val)))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
